<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use app\index\model\Sendmessage1;
use think\Cookie;
class Sendmessage extends Common
{
	/*
	*	发送短信接口
	*/
	public function index(Request $request)
	{
		//实例化model
		$model = new Sendmessage1;
		//接收手机号
		$mobile = $request->param("tel");
		//$mobile = '17601624430';
		//验证码
		$code = $model->createCode(4,1);
		Cookie::set('code',$code,60);
		$post_data = "account=C02343298&password=e20ed35afd656249ca645db630cc47d3&mobile=".$mobile."&content=".rawurlencode("您的验证码是：".$code."。请不要把验证码泄露给其他人。");
		$arr = $model->sendPost($post_data);
		$arr['code'] = $code;
		//print_r($arr);die;
		echo callback(self::$callback,$arr);
	}
	/*
	*		验证验证码是否正确
	*/
	public function verify(Request $request)
	{
		$code = $request->param("code");
		$scode = Cookie::get('code');
		if($code==$scode&&$code!=''){
			$arr['status'] = 200;
			$arr['msg'] = '成功';
		}else{
			$arr['status'] = 204;
			$arr['msg'] = '验证码不正确';
		}
		echo callback(self::$callback,$arr);
	}
}

